#ifndef WALKAWARE_SERVICES_SERVICE_H
#define WALKAWARE_SERVICES_SERVICE_H

#include <QThread>

namespace WalkaWare
{

namespace Services
{

class Service : public QObject
{
	Q_OBJECT

	public:

		typedef QObject BaseType;
		typedef Service ThisType;

		Service(void)
			: sThread(0)
		{
			;
		}

		virtual ~Service(void)
		{
			this->quit();
			delete this->sThread;
		}

		bool isRunning(void) const
		{
			return this->sThread->isRunning();
		}

	signals:

		void started  (void);
		void finished (void);

	public slots:

		virtual void start(void)
		{
			this->quit();
			this->sThread->start();
		}

		virtual void quit(void)
		{
			if (!this->isRunning()) return;

			this->sThread->quit();
			this->sThread->wait();
		}

	protected:

		QThread * sThread;

	private:

		Q_DISABLE_COPY(Service)
};

} // end namespace Services

} // end namespace WalkaWare

#endif // WALKAWARE_SERVICE_SERVICE_H
